Embedded systems based on a read only memory program are equipped with a non-volatile memory potion, for instance an electrically erasable and programmable read only memory (EEPROM) that is used for customized data. These embedded systems are incorporated into portable electronic devices such as handhelds, mobile phones, IC-cards, etc. Such devices operate according to a program (software application) masked on the read only memory that defines its functionalities.
The manufacturers, before making available a product based on the masked ROM device, stores customized data and user data into a non-volatile memory portion. As an example, consider the case of an IC-card for a GSM application. The telecommunication operators or providers require as much space as possible for the manufactures of the IC-card in terms of memory space of the non-volatile memory portion. Such space is used for the user data (i.e., address book, SMS, etc.) as well as for their own customized data from the provider (i.e., special operator functionalities, proprietary authentication algorithms, etc.). Generally speaking, the more non-volatile memory space is available the more attractive the final product is from a marketing point of view.
Moreover, since there is often the need to change or fix the ROM software functionalities without re-masking, it would be very important to have an efficient extending or patching mechanism for hooking new instructions to the ROM for picking them up from the non-volatile memory portion.
To extend or patch the ROM functionalities, the masked program needs to be sensitive to the patching mechanisms. According to the prior art, these mechanisms are based on the principle of replacing groups of masked ROM instructions, also known as subroutines, with new set of instructions. In other words, a new subroutine is stored in the additional non-volatile memory portion (e.g., EEPROM, Flash, etc.). This approach, however, suffers two problems. One problem is that the new subroutine stored in the non-volatile memory portion cannot reuse the calling ROM subroutine. A second problem is that it is not possible to reuse the ROM subroutine since the size of an EEPROM subroutine will be as large as the size of ROM subroutine that needs to be replaced.
FIG. 1 is a schematic and simplified view showing how the common patching mechanism of the prior art works. As may be appreciated, during execution of a ROM subroutine there might be a call to the EEPROM subroutine to be executed in place of the ROM instructions. However, after having executed the EEPROM instructions there is no possibility to reuse the ROM instructions without causing a recursive endless action.